package com.example.hw2.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "student")
public class Student implements Serializable {
    //private List<Lesson> lessonList;
    @Id
    @Column(name = "sid")
    private String SId;

    @Column(name = "sname")
    @Size(min = 2, message = "Name must be at least 2 characters long")
    private String SName;

    @Column(name = "sgrade")
    private String SGrade;

    @Column(name = "smajor")
    private String SMajor;

    @Column(name = "scollege")
    private String SCollege;



    @Override
    public boolean equals(Object o) {
        if (this == o) {return true;}
        if (o == null || getClass() != o.getClass()) {return false;}
        com.example.hw2.entity.Student that = (com.example.hw2.entity.Student) o;
        return Objects.equals(SName, that.SName) &&
                Objects.equals(SGrade, that.SGrade) &&
                Objects.equals(SId, that.SId) &&
                Objects.equals(SMajor, that.SMajor) &&
                Objects.equals(SCollege, that.SCollege);
    }

    @Override
    public int hashCode() {
        return Objects.hash(SName, SGrade, SId, SMajor, SCollege);
    }
}
